// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Inference;

[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Inference.Json.LlamaServiceSettingsConverter))]
public sealed partial class LlamaServiceSettings
{
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public LlamaServiceSettings(string modelId, string url)
	{
		ModelId = modelId;
		Url = url;
	}
#if NET7_0_OR_GREATER
	public LlamaServiceSettings()
	{
	}
#endif
#if !NET7_0_OR_GREATER
	[System.Obsolete("The type contains required properties that must be initialized. Please use an alternative constructor to ensure all required values are properly set.")]
	public LlamaServiceSettings()
	{
	}
#endif
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	internal LlamaServiceSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
	{
		_ = sentinel;
	}

	/// <summary>
	/// <para>
	/// For a <c>text_embedding</c> task, the maximum number of tokens per input before chunking occurs.
	/// </para>
	/// </summary>
	public int? MaxInputTokens { get; set; }

	/// <summary>
	/// <para>
	/// The name of the model to use for the inference task.
	/// Refer to the Llama downloading models documentation for different ways of getting a list of available models and downloading them.
	/// Service has been tested and confirmed to be working with the following models:
	/// </para>
	/// <list type="bullet">
	/// <item>
	/// <para>
	/// For <c>text_embedding</c> task - <c>all-MiniLM-L6-v2</c>.
	/// </para>
	/// </item>
	/// <item>
	/// <para>
	/// For <c>completion</c> and <c>chat_completion</c> tasks - <c>llama3.2:3b</c>.
	/// </para>
	/// </item>
	/// </list>
	/// </summary>
	public
#if NET7_0_OR_GREATER
	required
#endif
	string ModelId { get; set; }

	/// <summary>
	/// <para>
	/// This setting helps to minimize the number of rate limit errors returned from the Llama API.
	/// By default, the <c>llama</c> service sets the number of requests allowed per minute to 3000.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.RateLimitSetting? RateLimit { get; set; }

	/// <summary>
	/// <para>
	/// For a <c>text_embedding</c> task, the similarity measure. One of cosine, dot_product, l2_norm.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.LlamaSimilarityType? Similarity { get; set; }

	/// <summary>
	/// <para>
	/// The URL endpoint of the Llama stack endpoint.
	/// URL must contain:
	/// </para>
	/// <list type="bullet">
	/// <item>
	/// <para>
	/// For <c>text_embedding</c> task - <c>/v1/inference/embeddings</c>.
	/// </para>
	/// </item>
	/// <item>
	/// <para>
	/// For <c>completion</c> and <c>chat_completion</c> tasks - <c>/v1/openai/v1/chat/completions</c>.
	/// </para>
	/// </item>
	/// </list>
	/// </summary>
	public
#if NET7_0_OR_GREATER
	required
#endif
	string Url { get; set; }
}

public readonly partial struct LlamaServiceSettingsDescriptor
{
	internal Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettings Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public LlamaServiceSettingsDescriptor(Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettings instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public LlamaServiceSettingsDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor(Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettings instance) => new Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettings(Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// For a <c>text_embedding</c> task, the maximum number of tokens per input before chunking occurs.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor MaxInputTokens(int? value)
	{
		Instance.MaxInputTokens = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The name of the model to use for the inference task.
	/// Refer to the Llama downloading models documentation for different ways of getting a list of available models and downloading them.
	/// Service has been tested and confirmed to be working with the following models:
	/// </para>
	/// <list type="bullet">
	/// <item>
	/// <para>
	/// For <c>text_embedding</c> task - <c>all-MiniLM-L6-v2</c>.
	/// </para>
	/// </item>
	/// <item>
	/// <para>
	/// For <c>completion</c> and <c>chat_completion</c> tasks - <c>llama3.2:3b</c>.
	/// </para>
	/// </item>
	/// </list>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor ModelId(string value)
	{
		Instance.ModelId = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// This setting helps to minimize the number of rate limit errors returned from the Llama API.
	/// By default, the <c>llama</c> service sets the number of requests allowed per minute to 3000.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor RateLimit(Elastic.Clients.Elasticsearch.Inference.RateLimitSetting? value)
	{
		Instance.RateLimit = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// This setting helps to minimize the number of rate limit errors returned from the Llama API.
	/// By default, the <c>llama</c> service sets the number of requests allowed per minute to 3000.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor RateLimit()
	{
		Instance.RateLimit = Elastic.Clients.Elasticsearch.Inference.RateLimitSettingDescriptor.Build(null);
		return this;
	}

	/// <summary>
	/// <para>
	/// This setting helps to minimize the number of rate limit errors returned from the Llama API.
	/// By default, the <c>llama</c> service sets the number of requests allowed per minute to 3000.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor RateLimit(System.Action<Elastic.Clients.Elasticsearch.Inference.RateLimitSettingDescriptor>? action)
	{
		Instance.RateLimit = Elastic.Clients.Elasticsearch.Inference.RateLimitSettingDescriptor.Build(action);
		return this;
	}

	/// <summary>
	/// <para>
	/// For a <c>text_embedding</c> task, the similarity measure. One of cosine, dot_product, l2_norm.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor Similarity(Elastic.Clients.Elasticsearch.Inference.LlamaSimilarityType? value)
	{
		Instance.Similarity = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The URL endpoint of the Llama stack endpoint.
	/// URL must contain:
	/// </para>
	/// <list type="bullet">
	/// <item>
	/// <para>
	/// For <c>text_embedding</c> task - <c>/v1/inference/embeddings</c>.
	/// </para>
	/// </item>
	/// <item>
	/// <para>
	/// For <c>completion</c> and <c>chat_completion</c> tasks - <c>/v1/openai/v1/chat/completions</c>.
	/// </para>
	/// </item>
	/// </list>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor Url(string value)
	{
		Instance.Url = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettings Build(System.Action<Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor> action)
	{
		var builder = new Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettingsDescriptor(new Elastic.Clients.Elasticsearch.Inference.LlamaServiceSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}